package com.edu.javaweb.service.impl;

import com.edu.javaweb.mapper.AdminMapper;
import com.edu.javaweb.pojo.Admin;
import com.edu.javaweb.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;
    @Override
    public Boolean adminLogin(Admin admin, HttpSession session) {
        String account = admin.getAccount();
        Admin admin1 = adminMapper.queryByAccount(account);
        if (admin1!=null){
            if (admin1.getPassword().equals(admin.getPassword())){
                session.setAttribute("admin",admin1);
                return true;
            }
        }
        return false;

    }

    @Override
    public Admin getAdmin(String account) {
        return adminMapper.queryByAccount(account);
    }

    @Override
    public void cgAdminPassword(Admin admin) {
        adminMapper.upById(admin);
    }
}
